﻿using Domain.Examin;
using Infratructure.Interface;
using MediatR;
using MES.Server.API.Application.Command.ApprovalProcess;
using ReturnValue;

namespace MES.Server.API.Application.Handler.ApprovalProcess
{
    public class GetApprovalNodeHandler : IRequestHandler<GetApprovalNodeCommand, ApiResult<List<ApprovalNodeModel>>>
    {
        private readonly IRepository<ApprovalNodeModel> approcalNodeRepo;

        public GetApprovalNodeHandler(IRepository<ApprovalNodeModel> approcalNodeRepo)
        {
            this.approcalNodeRepo = approcalNodeRepo;
        }
        public Task<ApiResult<List<ApprovalNodeModel>>> Handle(GetApprovalNodeCommand request, CancellationToken cancellationToken)
        {
            var res=new ApiResult<List<ApprovalNodeModel>>();
            var approcalNode= approcalNodeRepo.GetAll().Where(x=>!x.IsDel);
            res.Data= approcalNode.ToList();
            res.Message = "查询成功";
            res.Code=StatusCode.Success;
            return Task.FromResult(res);
        }
    }
}
